package com.ruoyi.system.service.impl;

import java.math.BigDecimal;
import java.util.List;

import com.ruoyi.db.domain.system.PcRaiseSystemConfig;
import com.ruoyi.db.mapper.system.PcRaiseSystemConfigMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.service.IPcRaiseSystemConfigService;

import javax.transaction.Transactional;

/**
 * 【请填写功能名称】Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-08-05
 */
@Service
@Transactional(rollbackOn = Exception.class)
public class PcRaiseSystemConfigServiceImpl implements IPcRaiseSystemConfigService 
{
    @Autowired
    private PcRaiseSystemConfigMapper pcRaiseSystemConfigMapper;

    /**
     * 查询【请填写功能名称】
     * 
     * @param id 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    @Override
    public PcRaiseSystemConfig selectPcRaiseSystemConfigById(Long id)
    {
        return pcRaiseSystemConfigMapper.selectPcRaiseSystemConfigById(id);
    }

    /**
     * 查询【请填写功能名称】列表
     * 
     * @param pcRaiseSystemConfig 【请填写功能名称】
     * @return 【请填写功能名称】
     */
    @Override
    public List<PcRaiseSystemConfig> selectPcRaiseSystemConfigList(PcRaiseSystemConfig pcRaiseSystemConfig)
    {
        List<PcRaiseSystemConfig> list = pcRaiseSystemConfigMapper.selectPcRaiseSystemConfigList(pcRaiseSystemConfig);
        for (PcRaiseSystemConfig config:list) {
            config.setShareRate(config.getShareRate().multiply(new BigDecimal(100)));
            config.setFirstOrderSilverRate(config.getFirstOrderSilverRate().multiply(new BigDecimal(100)));
            config.setLockReturnGoldRate(config.getLockReturnGoldRate().multiply(new BigDecimal(100)));
            config.setLockReturnSilverRate(config.getLockReturnSilverRate().multiply(new BigDecimal(100)));
            config.setNowReturnGoldRate(config.getNowReturnGoldRate().multiply(new BigDecimal(100)));
        }
        return list;
    }

    /**
     * 新增【请填写功能名称】
     * 
     * @param pcRaiseSystemConfig 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int insertPcRaiseSystemConfig(PcRaiseSystemConfig pcRaiseSystemConfig)
    {
        return pcRaiseSystemConfigMapper.insertPcRaiseSystemConfig(pcRaiseSystemConfig);
    }

    /**
     * 修改【请填写功能名称】
     * 
     * @param pcRaiseSystemConfig 【请填写功能名称】
     * @return 结果
     */
    @Override
    public int updatePcRaiseSystemConfig(PcRaiseSystemConfig pcRaiseSystemConfig)
    {
        pcRaiseSystemConfig.setShareRate(pcRaiseSystemConfig.getShareRate().divide(new BigDecimal(100)));
        pcRaiseSystemConfig.setNowReturnGoldRate(pcRaiseSystemConfig.getNowReturnGoldRate().divide(new BigDecimal(100)));
        pcRaiseSystemConfig.setLockReturnSilverRate(pcRaiseSystemConfig.getLockReturnSilverRate().divide(new BigDecimal(100)));
        pcRaiseSystemConfig.setFirstOrderSilverRate(pcRaiseSystemConfig.getFirstOrderSilverRate().divide(new BigDecimal(100)));
        pcRaiseSystemConfig.setLockReturnGoldRate(pcRaiseSystemConfig.getLockReturnGoldRate().divide(new BigDecimal(100)));
        return pcRaiseSystemConfigMapper.updatePcRaiseSystemConfig(pcRaiseSystemConfig);
    }

    /**
     * 批量删除【请填写功能名称】
     * 
     * @param ids 需要删除的【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePcRaiseSystemConfigByIds(Long[] ids)
    {
        return pcRaiseSystemConfigMapper.deletePcRaiseSystemConfigByIds(ids);
    }

    /**
     * 删除【请填写功能名称】信息
     * 
     * @param id 【请填写功能名称】主键
     * @return 结果
     */
    @Override
    public int deletePcRaiseSystemConfigById(Long id)
    {
        return pcRaiseSystemConfigMapper.deletePcRaiseSystemConfigById(id);
    }
}
